package com.zzu.base.controller.avatar;

import com.zzu.base.common.pojo.ResultResponse;
import com.zzu.base.service.UserAvatarService;
import com.zzu.base.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/user/avatar")
@Tag(name = "用户头像")
@PreAuthorize("hasPermission(null,'restricted_use')")
public class AvatarController {
    @Resource
    private UserAvatarService userAvatarService;
    @Operation(method = "用户头像上传")
    @PostMapping("add")
    public ResultResponse<String> userAvatarAdd(@RequestParam("file") MultipartFile file) {
        return ResultResponse.success(userAvatarService.addUserAvatar(file));
    }
    @Operation(method = "用户头像url获取")
    @GetMapping("get")
    public ResultResponse<String> userAvatarGet() {
        return ResultResponse.success(userAvatarService.getUserAvatarUrl());
    }
}
